package cc.geeksearch.ble

import android.util.Log

object WalleLog {
    private var PREFIX = "WalleBleKit "
    var DEBUG: Boolean = true

    fun init(prefix: String) {
        PREFIX = prefix
    }

    fun d(tag: String?, message: String?) {
        if (DEBUG) {
            Log.d(tag, PREFIX + check(message))
        }
    }

    fun e(tag:String, message: String?) {
        if (DEBUG) {
            Log.e(tag, PREFIX + check(message))
        }
    }

    fun w(tag: String?, message: String?) {
        if (DEBUG) {
            Log.w(tag,  PREFIX + check(message))
        }
    }


    fun i(tag: String?, message: String?) {
        if (DEBUG) {
            Log.i(tag, PREFIX +  check(message))
        }
    }

    fun v(tag: String?, message: String?) {
        if (DEBUG) {
            Log.v(tag, PREFIX +  check(message))
        }
    }

    private fun check(message: String?): String {
        if(message == null){
            return "[NULL]"
        }
        if(message.isEmpty()){
            return "[EMPTY]"
        }
        return message
    }
}
